<?php
session_start();
define('MYLAB_WEB_PAGE_TO_ROOT', '../../');
require_once MYLAB_WEB_PAGE_TO_ROOT . 'dvwa/includes/MyPage.inc.php';

if (isset($_POST['Login'])) {
    // 写死账号密码
    if ($_POST['username'] === 'admin' && $_POST['password'] === '123456') {
        $_SESSION['user'] = 'admin';
        header('Location: ' . MYLAB_WEB_PAGE_TO_ROOT . 'index.php');
        exit;
    } else {
        $error = '<p style="color:red">账号或密码错误。</p>';
    }
}
?>
<!DOCTYPE html>
<html>
<head><meta charset="utf-8"><title>登录</title></head>
<body>
<div class="body_padded">
  <h1>请登录</h1>
  <form method="post">
    Username:<br><input type="text" name="username"><br>
    Password:<br><input type="password" name="password"><br><br>
    <input type="submit" name="Login" value="Login">
  </form>
  <?php echo $error ?? ''; ?>
</div>
</body>
</html>